 package com.cocos.game;

 import android.util.Log;

 import org.json.JSONObject;

 import cn.thinkingdata.analytics.TDAnalytics;
 import cn.thinkingdata.analytics.TDConfig;

 public class TDHelper {
     private static final String appId = "1f67a26551ea4780bc9fad5ecd4315a0";
     private static final String serverUrl = "https://tareport.triwingames.com";
     public static void init() {
         TDConfig config = TDConfig.getInstance(AppActivity.act, appId, serverUrl);
         TDAnalytics.init(config);
         //开启自动采集事件
         TDAnalytics.enableAutoTrack(TDAnalytics.TDAutoTrackEventType.APP_START
                 | TDAnalytics.TDAutoTrackEventType.APP_END
                 | TDAnalytics.TDAutoTrackEventType.APP_INSTALL
                 | TDAnalytics.TDAutoTrackEventType.APP_CRASH);
     }

     public static void login(String accountId) {
         TDAnalytics.login(accountId);
     }

     public static void track(String eventName, String json) {
         try {
             JSONObject properties = new JSONObject(json);
             TDAnalytics.track(eventName, properties);
         } catch (Exception e) {
             e.printStackTrace();
         }
     }

     public static void userSet(String json) {
        //  Log.d("COREXJ", "userSet: " + json);
         try {
             JSONObject userProperties = new JSONObject(json);
             TDAnalytics.userSet(userProperties);
         } catch (Exception e) {
             e.printStackTrace();
         }
     }

 }
